/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFT0Array
  \brief The plastic scintillator array next to T0 in F1, for pos detection
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2023-12-19
  \date 2023-12-19 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2023-12-19   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFT0Array_h
#define ETFT0Array_h

#include <map>
#include "ETFTOFWall.h"

class ETFT0Array : public ETFTOFWall{
public:
  ETFT0Array() : ETFTOFWall(){}
  /// \param ns: number of strips; \param width: (effective) strip width in mm
  ETFT0Array(const char *name, int ns = 30, double width = 41.67, double length = 1200.);
  virtual ~ETFT0Array();

  virtual void Initialize() override; ///< initialize the detector
  virtual void Print() override;

  virtual void Register() override; ///< register hits to the main output tree
  virtual void PostAssign() override; ///< finish the processing of all the assigned data
  /// only 1 strip is supposed to be fired: this method filter the others
  virtual void Filter();
  int OptimalStripId() const{ return fStripIdM; }
  ETFPlaHit *OptimalHit() const; // return GetStrip(fStripIdM);
  double x_f1() const{ return fXF1; }
  double GetOptimalHitX() const{ return fXF1; }

  // ClassDefOverride(ETFT0Array, 0);

protected:
  /// \param stripId: 0-30, along x increasing direction
  /// \param udvh: 0-1-2-3: uv, uh, dv, dh
  virtual void AddHit(const ETFRawChannel *ch, int stripId, int udvh) override;

  int fStripIdM; ///< id of the optimal strip
  double fXF1; ///< x1 position
  // double fT0; //! time of tstart next to this t0arr - we want them also close in time
};

#endif
